<#assign module="zhuanche"/>
<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/chosen.min.css">
<style>
.chosen-container{font-size: 14px;min-width: 370px;}
</style>
<style>
	/* autocomplete */
	div.ac {border: 1px solid #ccc;position: absolute;display: none;overflow: auto;background-color: #ffffff;z-index:999999;}
	div.ac > ul {margin-top:10px;padding:0;}
	div.ac > ul > li {height:33px;line-height:33px;cursor:pointer;}
	div.ac > ul > li:hover{background:#eee;}
	div.ac > ul > li > div span {padding-left:15px;}
	div.ac > ul > li > div span em {color:red;font-style: normal;}
</style>

</@override>
<@override name="body">

<div class="tabbable tabs-left">
	<div class="row">
		<div class="col-xs-12">
			<div class="orders-navt">
				<ul class="orders-nav">
	                <@shiro.hasPermission name='zhuanCar'>
	                	<li><a  href="${ctx}/zhuanche/cars" >车辆</a></li>
	                </@shiro.hasPermission>
	                <@shiro.hasPermission name='zhuanCar'>
	                	<li class="orders-click"><a data-toggle="tab" href="${ctx}/zhuanche/carTypes" class="orders-click-a" >类型</a></li>
	                </@shiro.hasPermission>
	            </ul>
	    	</div>
	    	<div class="orders-navh">
		       <button class="pull-right btn btn-primary addCarType"><i class="icon-plus"></i>&nbsp;添加车辆类型</button>
			</div>
		</div>
	</div>
</div>

<!--列表-->
<table class="table table-condensed table-striped">
	<tbody>
		<tr>
			<th class="col-xs-4" style='width:35%'>汽车类型(<span style="font-size:14px;color:red;">点击车型名称展开或收起</span>)</th>
			<!--<th class="col-xs-4" style='width:25%'>是否是出租车</th>-->
			<th class="col-xs-4" style='width:30%'>APP上显示顺序(从左到右 由小到大)</th>
			<th style="width:35%;text-align: right;" class="col-xs-4 text-right">操作</th>
		</tr>
	</tbody>
</table>
<div id="carTypeList">
	
</div>
<div>
	<ul class="pagination pull-left pagination-sm pageshow" id="carTypetotal">
	</ul>
</div>
<!--添加汽车类型-->
<div class="form-horizontal">
	<div class="modal fade" id="dialog_carType">
	   <div class="modal-dialog" style="margin-left:25%;width:50%;">
	     <div class="modal-content" style="width:100%;height:auto;">
	    	<div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        	<h4 class="modal-title">添加汽车类型</h4>
	        </div>
		    <div class="modal-body">
	      	<form action=""  method="post">
		         <div class="form-group">
                    <label class="col-sm-2 control-label">类型名称:</label>
                    <div class="col-sm-2">
                    	<input id="name"  class="form-control" ></input>
                    </div>
                    <!--
                     <label class="col-sm-2 control-label">是否是出租车:</label>
                    <div class="col-sm-2" style="margin-top:5px;">
                    	<input type="radio" name="ifTaxi" value="1">是
					  	<input type="radio" name="ifTaxi" value="0" checked="checked">否 
					</div>
                    -->
                    <label class="col-sm-2 control-label">排列顺序:</label>
	                <div class="col-sm-2">
	                	<input id="sequence" class="form-control"></input>
	                </div>
				 </div>
				 <div class="form-group">
				 	<label class="col-sm-2 control-label">选择可接单类型:</label>
				 </div>
				 <div class="form-group col-sm-12">
				 	<div class="col-sm-1"></div>
					 <div class="form-group col-sm-11" id="accessibleTypeDiv">
					 	<label class="control-label"></label>
					 </div>
				 </div>
				 <div class="form-group">
                    <label class="col-sm-2 control-label">类型图片:</label>
                    <label class="col-sm-4" style="margin-top:6px;"><span style="font-size=30px;color:red;">点击图片选择,在APP客户端显示使用</span></label>
                 </div>
				 <div class="form-group">
                  	<div class="col-sm-2">
                  	</div>
                  	<div class="col-sm-10">
                  		<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture1.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture2.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture3.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture4.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture5.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture6.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture7.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture" src="${ctx}/assets/img/zhuanchecartype/picture8.png"  style="width:100%;height:100%;"/>
						</div>
					</div>
                 </div>
			     <div class="form-group">
                 	  <div class="col-sm-4">
                	  </div>
                	  <div class="col-sm-4">
					      <input  type="button" class="btn btn-primary" id="save" value="确定">
					      <button type="button" class="btn btn-default" id="close_modal_memo">关闭</button>
		        	  </div>
		          </div>  
		  	</form>
	     	</div>
	     </div>
	  </div>
	</div>
</div>
<!--编辑汽车类型-->
<div class="form-horizontal">
	<div class="modal fade" id="dialog_carType_update">
	   <div class="modal-dialog" style="margin-left:25%;width:50%;">
	     <div class="modal-content" style="width:100%;height:auto;">
	    	<div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        	<h4 class="modal-title">编辑类型</h4>
	        </div>
		    <div class="modal-body">
	      	<form action=""  method="post">
	      		 <input type="hidden" id="carTypeId"/>
		         <div class="form-group">
                    <label class="col-sm-2 control-label">汽车类型:</label>
                    <div class="col-sm-2">
                    	<input id="name2"  class="form-control" ></input>
                    </div>
                    <!--
                    <label class="col-sm-2 control-label">是否是出租车:</label>
                    <div class="col-sm-2" style="margin-top:5px;">
                    	<input type="radio" id="ifTaxi1" name="ifTaxiUpdate" value="1">是
					  	<input type="radio" id="ifTaxi2" name="ifTaxiUpdate" value="0" checked="checked">否 
					</div>
                    -->
                    <label class="col-sm-2 control-label">排列顺序:</label>
	                <div class="col-sm-2">
	                	<input id="sequence2" class="form-control" ></input>
	                </div>
				 </div>
				 <div class="form-group">
					 	<label class="col-sm-2 control-label">选择可接单类型:</label>
				 </div>
				 
				 <div class="form-group col-sm-12">
				 	<div class="col-sm-1"></div>
					 <div class="form-group col-sm-11" id="accessibleTypeDiv2">
					 	<label class="control-label"></label>
					 </div>
				 </div>
				 
                 <div class="form-group">
                    <label class="col-sm-2 control-label">类型图片:</label>
                    <label class="col-sm-4"  style="margin-top:6px;"><span style="font-size=30px;color:red;">点击图片选择,在APP客户端显示使用</span></label>
                 </div>
				 <div class="form-group">
                  	<div class="col-sm-2">
                  	</div>
                  	<div class="col-sm-10">
                  		<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture1.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture2.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture3.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture4.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture5.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture6.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture7.png"  style="width:100%;height:100%;"/>
						</div>
						<div style="margin-left:2px;margin-right:2px;float:left;height:150px;width:160px;">
							<img class="picture_update" src="${ctx}/assets/img/zhuanchecartype/picture8.png"  style="width:100%;height:100%;"/>
						</div>
					</div>
				   <div class="form-group">
                 	  <div class="col-sm-6">
                	  </div>
                	  <div class="col-sm-3" style="margin-top:15px;">
					      <input  type="button" class="btn btn-primary" id="update" value="修改">
					      <button type="button" class="btn btn-default" id="close_modal_update">取消</button>
		        	  </div>
		           </div>  
		  	</form>
	     	</div>
	     </div>
	  </div>
	</div>
</div>



<!--开通公司-->
<div class="form-horizontal">
	<div class="modal fade" id="dialog_carTypeCompany_create">
	   <div class="modal-dialog">
	     <div class="modal-content">
	    	<div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        	<h4 class="modal-title">开通公司</h4>
	        </div>
		    <div class="modal-body">
	      	<form action=""  method="post">
	      		<input type="hidden" id="carTypeId"/>
		         <div class="form-group">
                    <label class="col-sm-3 control-label">汽车类型:</label>
                    <div class="col-sm-8">
                    	<label class="col-sm-4 control-label" id="carTypeName"></label>
                    </div>
				 </div>
	      		 <div class="form-group">
	                <label class="col-sm-3 control-label">所属公司:</label>
	                <div class="col-sm-8">
		                <select class="form-control" id="companyId_company" >
							<#if companys??>
								<#list companys as company>
									<option value="${company.id}" <#if companyId?? && companyId==company.id>selected="selected"</#if>>${company.abbreviation?if_exists}</option>
								</#list>
							</#if>
						</select>
	                </div>
				 </div>
	      		 <div class="form-group">
	                <label class="col-sm-3 control-label">立即用车收费:</label>
                	<div class="col-sm-8">
                		<input type="hidden" id="tzAreaId">
                		<!--<input type="text" class="form-control" id="tangzuAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="tangzuAreaId_company" class="form-control"></select>
	                </div>
				 </div>
	      		 <div class="form-group">
	                <label class="col-sm-3 control-label">日租收费:</label>
                	<div class="col-sm-8">
                		<input type="hidden" id="rzAreaId">
                		<!--<input type="text" class="form-control" id="rizuAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="rizuAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">半日收费:</label>
	                <div class="col-sm-8">
                		<input type="hidden" id="brzAreaId">
                		<!--<input type="text" class="form-control" id="banrizuAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="banrizuAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">接机收费:</label>
                	<div class="col-sm-8">
                		<input type="hidden" id="jjAreaId">
                		<!--<input type="text" class="form-control" id="jiejiAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="jiejiAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">送机收费:</label>
	                <div class="col-sm-8">
                		<input type="hidden" id="sjAreaId">
                		<!--<input type="text" class="form-control" id="songjiAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="songjiAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
	         	 <div class="form-group">
	                <label class="col-sm-3 control-label">接站收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="jzAreaId">
                		<!--<input type="text" class="form-control" id="jiezhanAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="jiezhanAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">送站收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="szAreaId">
                		<!--<input type="text" class="form-control" id="songzhanAreaId_company" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="songzhanAreaId_company" class="dept_select"></select>
	                </div>
				 </div>
				 <div class="form-group">
             	 	<div class="col-sm-6">
            	 	</div>
            	 	<div class="col-sm-3">
				      <input  type="button" class="btn btn-primary" id="startService_company" value="开通">
				      <button type="button" class="btn btn-default" id="close_modal_company">取消</button>
	        	  	</div>
	           </div>  
		  	</form>
	     	</div>
	     </div>
	  </div>
	</div>
</div>


<!--修改公司车型收费-->
<div class="form-horizontal">
	<div class="modal fade" id="dialog_carTypeCompany_update">
	   <div class="modal-dialog">
	     <div class="modal-content">
	    	<div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        	<h4 class="modal-title">修改公司收费</h4>
	        </div>
		    <div class="modal-body">
	      	<form action=""  method="post">
	      		<input type="hidden" id="companyId_update"/>
	      		<input type="hidden" id="carTypeId_update"/>
		         <div class="form-group">
                    <label class="col-sm-3 control-label">汽车类型:</label>
                    <div class="col-sm-8">
                    	<label class="control-label" id="carTypeName_update"></label>
                    </div>
				 </div>
	      		 <div class="form-group">
	                <label class="col-sm-3 control-label">所属公司:</label>
	                <div class="col-sm-8">
	                	<label id="companyName_update" class="control-label" ></label>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">立即用车收费:</label>
	                <div class="col-sm-8">
                		<input type="hidden" id="tzAreaId_update">
                		<!--<input type="text" class="form-control" id="tangzuAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="tangzuAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">日租收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="rzAreaId_update">
                		<!--<input type="text" class="form-control" id="rizuAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="rizuAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">半日收费:</label>
	                <div class="col-sm-8">
	               		<input type="hidden" id="brzAreaId_update">
                		<!--<input type="text" class="form-control" id="banrizuAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="banrizuAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">接机收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="jjAreaId_update">
                		<!--<input type="text" class="form-control" id="jiejiAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="jiejiAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">送机收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="sjAreaId_update">
                		<!--<input type="text" class="form-control" id="songjiAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="songjiAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">接站收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="jzAreaId_update">
                		<!--<input type="text" class="form-control" id="jiezhanAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="jiezhanAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
		         <div class="form-group">
	                <label class="col-sm-3 control-label">送站收费:</label>
	                <div class="col-sm-8">
	                	<input type="hidden" id="szAreaId_update">
                		<!--<input type="text" class="form-control" id="songzhanAreaId_company_update" placeholder="请输入收费标准名称" autocomplete="off"/>-->
                		<select id="songzhanAreaId_company_update" class="form-control"></select>
	                </div>
				 </div>
				 <div class="form-group">
             	 	<div class="col-sm-6">
            	 	</div>
            	 	<div class="col-sm-3">
				      <input  type="button" class="btn btn-primary" id="startService_company_update" value="修改">
				      <button type="button" class="btn btn-default" id="close_modal_company_update">取消</button>
	        	  	</div>
	           </div>  
		  	</form>
	     	</div>
	     </div>
	  </div>
	</div>
</div>

</@override>
<@override name="footer">
<script type="text/javascript">
  window.company = {isMainCompany:false};
 <@shiro.isMainCompany>
 	window.company = {isMainCompany:true};
 </@shiro.isMainCompany>
  window.deleteZhuancheType =false;
 <@shiro.hasPermission name='deleteZhuancheType'>
 	window.deleteZhuancheType = true;
 </@shiro.hasPermission>
</script>

<script src="${ctx}/assets/js/jquery.paging.min.js"></script>

<script src="${ctx}/assets/js/ajaxfileupload.js"></script>
<script src="${ctx}/assets/js/bootstrap-multiselect.js"></script>
<script src="${ctx}/assets/js/freight/jquery-labelauty.js"></script>
<script src="${ctx}/assets/js/jquery.autocomplete.js"></script>

<script src="${ctx}/assets/js/zhuanche/carType.js"></script>
<script src="${ctx}/assets/js/chosen.jquery.min.js"></script>
<script type="text/javascript">
	var thisButton;
	var thisButton_company;
	function deleteCarType() {
		if(thisButton.attr("data-value").trim()==null  || thisButton.attr("data-value").trim()==""){
			$.scojs_message("车辆类型不存在！", $.scojs_message.TYPE_ERROR);
			return false;
		}
	    $.get('${ctx}/zhuanche/deleteCarTypeV4up',{'id':thisButton.attr("data-value")},function(data){
	            if(data.code==0){
	            	thisButton.parent().parent().remove();
	                $.scojs_message('汽车类型删除成功', $.scojs_message.TYPE_OK);
	                 setTimeout(function(){
							window.location.reload(true);
						}, 800);
	            } else {
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	            }
	    },'json');
	}
	function deleteCarTypeCompany() {
		if(thisButton_company.attr("data-value").trim()==null  || thisButton_company.attr("data-value").trim()==""){
			$.scojs_message("公司车型不存在！", $.scojs_message.TYPE_ERROR);
			return false;
		}
	    $.get('${ctx}/zhuanche/deleteCarTypeCompany',{'carTypeCompanyId':thisButton_company.attr("data-value")},function(data){
            if(data.code==0){
            	thisButton_company.parent().parent().remove();
                $.scojs_message('公司车型取消成功', $.scojs_message.TYPE_OK);
                 setTimeout(function(){
						window.location.reload(true);
					}, 800);
            } else {
                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
            }
	    },'json');
	}
	$(document).ready(function(){
	
	    $(document).on("click",".deletethis",function(){
	          thisButton = $(this);
	          var confirm = $.scojs_confirm({
	            content: "<span style='font-size:18px;color:red;'>你真的要删除该车型吗？已经开通的公司该车型也会被取消开通!</span>",
	            action:deleteCarType
	          });
	          confirm.show();
	    });
	    
	    $(document).on("click",".deleteTypeCompany",function(){
	          thisButton_company = $(this);
	          var confirm = $.scojs_confirm({
	            content: "你真的要取消开通该车型吗？专车车型不会被删除!",
	            action: deleteCarTypeCompany
	          });
	          confirm.show();
	    });
	});
	
	
//添加汽车类型
	$(document).on("click",".addCarType",function(){
		var pictures=$(".picture");
    	for(var i=0;i<pictures.length;i++){
			var p=pictures[i];
			$(p).parent().css("border","");
		}
    	$('#dialog_carType').modal();
    });
    $('#name').blur(function(){
    	if($(this).val().length>10){
    		$.scojs_message("名称过长,不超过10个字符", $.scojs_message.TYPE_ERROR);
    		$(this).val('');
    	}
    });
    var picture="/assets/img/zhuanchecartype/picture1.png";
    $(document).on("click",".picture",function(){
    	picture=$(this).attr("src");
    	var pictures=$(".picture");
    	for(var i=0;i<pictures.length;i++){
			var p=pictures[i];
			$(p).parent().css("border","0px");
		}
		$(this).parent().css("border","1px solid red");
    });
    
    $(document).on("click","#save",function(){
		var name=$('#name').val().trim();
		if(name==null  || name==""){
			$.scojs_message("汽车类型名称不正确！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		if($('#sequence').val().trim()==null  || $('#sequence').val().trim()==""){
			$.scojs_message("排序不能为空", $.scojs_message.TYPE_ERROR);
			return false;
		} else if (!(/(^[0-9]{1,9}$)/.test($('#sequence').val()))) {
			$.scojs_message("请输入数字排序", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var accessibleTypeArr=[];
		var accessibleType  = null;
		$("input[name=accessibleType]:checked").each(function(index,element){
			accessibleTypeArr.push($(element).val());
		});
		if(null!=accessibleTypeArr && accessibleTypeArr.length>0){
			accessibleType=accessibleTypeArr.join(",");
		}else{
			accessibleType="";
		}
 		$('#dialog_carType').modal("hide");
		$.post('${ctx}/zhuanche/createCarType',
			//{'name':$('#name').val(),'sequence':$('#sequence').val(),'accessibleType':accessibleType,'ifTaxi':$("input[name='ifTaxi']:checked").val(),'picture':picture},
			{'name':$('#name').val(),'sequence':$('#sequence').val(),'accessibleType':accessibleType,'picture':picture},
			function(data){
	           if(data.success){
	                $.scojs_message(data.message, $.scojs_message.TYPE_OK);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }else{
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }
	    },'json');
     });
    $("#close_modal_memo").click(function(){
		$('#dialog_carType').modal("hide");
	});

//修改汽车类型
	$('#name2').blur(function(){
    	if($(this).val().length>10){
    		$.scojs_message("名称过长,不超过10个字符", $.scojs_message.TYPE_ERROR);
    		$(this).val('');
    	}
    });
    var picture_update="/assets/img/zhuanchecartype/picture1.png";
	
	$(document).on("click",".updateCarType",function(){
		$("#carTypeId").val($(this).attr('cartypeId'));
		$("#name2").val($(this).attr('typeName'));
		$("#sequence2").val($(this).attr('sequence'));
		var checkbox = $("input[name='accessibleType2']");
		var accessibleType = $(this).attr('accessibleType').split(",");
		//var radio = $("input[name='ifTaxiUpdate']");
		var ifTaxi = $(this).attr('ifTaxi');
		if(checkbox.length>0){
			for(var i=0;i<checkbox.length;i++){
				if(accessibleType.indexOf(checkbox[i].value)!=-1){
					checkbox[i].checked=true;
				}else{
					checkbox[i].checked=false;
				}
				if(checkbox[i].value == $(this).attr('cartypeId')){
					$("#accessible"+$(this).attr('cartypeId')).hide();
				}else{
					$("#accessible"+checkbox[i].value).show();
				}
			}
		}
		/**
		if(radio.length>0){
			if (ifTaxi != null && ifTaxi != "null") {
				for(var j=0;j<radio.length;j++){
					if(radio[j].value == ifTaxi){
						radio[j].checked=true;
					}else{
						radio[j].checked=false;
					}
				}
			} else {
				radio[1].checked=true;
			}
		}
		*/
		picture_update=$(this).attr('picture');
		
    	var pictures=$(".picture_update");
    	for(var i=0;i<pictures.length;i++){
			var p=pictures[i];
			if(picture_update==$(p).attr("src")){
				$(p).parent().css("border","1px solid red");
			}else{
				$(p).parent().css("border","");
			}
		}
		
    	$('#dialog_carType_update').modal();
    });
    $(document).on("click",".picture_update",function(){
    	picture_update=$(this).attr("src");
    	var pictures=$(".picture_update");
    	for(var i=0;i<pictures.length;i++){
			var p=pictures[i];
			$(p).parent().css("border","0px");
		}
		$(this).parent().css("border","1px solid red");
    });
    
    $(document).on("click","#update",function(){
		if($('#name2').val().trim()==null  || $('#name2').val().trim()==""){
			$.scojs_message("汽车类型名称不正确！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		if($('#sequence2').val().trim()==null  || $('#sequence2').val().trim()==""){
			$.scojs_message("排序不能为空", $.scojs_message.TYPE_ERROR);
			return false;
		} else if (!(/(^[0-9]{1,9}$)/.test($('#sequence2').val()))) {
			$.scojs_message("请输入数字排序", $.scojs_message.TYPE_ERROR);
			return false;
		}
		if(picture_update==null || picture_update.trim()==""){
			$.scojs_message("请选择图片", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var accessibleTypeArr=[];
		var accessibleType  = null;
		$("input[name=accessibleType2]:checked").each(function(index,element){
			accessibleTypeArr.push($(element).val());
		});
		if(null!=accessibleTypeArr && accessibleTypeArr.length>0){
			accessibleType=accessibleTypeArr.join(",");
		}else{
			accessibleType="";
		}
		if(null!=accessibleTypeArr && accessibleTypeArr.length>0){
			accessibleType=accessibleTypeArr.join(",");
		}else{
			accessibleType="";
		}
		$.post('${ctx}/zhuanche/updateCarTypeV4up',
			{'id':$('#carTypeId').val(),'name':$('#name2').val(),'sequence':$('#sequence2').val(),
			//'accessibleType':accessibleType,'ifTaxi':$("input[name='ifTaxiUpdate']:checked").val(),'picture':picture_update},
			'accessibleType':accessibleType,'picture':picture_update},
			function(data){
	           if(data.success){
	                $.scojs_message(data.message, $.scojs_message.TYPE_OK);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }else{
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }
		    },'json');
	});
	$('#dialog_carType_update').modal("hide");
   
    $("#close_modal_update").click(function(){
		$('#dialog_carType_update').modal("hide");
	});

	//开通公司
    $("#close_modal_company").click(function(){
		$('#dialog_carTypeCompany_create').modal("hide");
	});
	$(document).on("click",".startService",function(){
		var typeName=$(this).attr("typeName");
		$("#carTypeName").html(typeName);
		$("#carTypeId").val($(this).attr("carTypeId"));
		$('#dialog_carTypeCompany_create').modal();
	});
    $(document).on("click","#startService_company",function(){
		if($('#companyId_company').val().trim()==null  || $('#companyId_company').val().trim()==""){
			$.scojs_message("请选择开通公司！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var tzId = $('#tangzuAreaId_company').val().trim();
    	var tzName = $("#tangzuAreaId_company").next().find("a").text();
		if(tzId ==null  || tzId =="" || tzName ==null || tzName ==""){
			$.scojs_message("请选择立即用车收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var rzId = $('#rizuAreaId_company').val().trim();
    	var rzName = $("#rizuAreaId_company").next().find("a").text();
		if(rzId ==null  || rzId =="" || rzName ==null || rzName ==""){
			$.scojs_message("请选择日租收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var brzId = $('#banrizuAreaId_company').val().trim();
    	var brzName = $("#banrizuAreaId_company").next().find("a").text();
		if(brzId ==null  || brzId =="" || brzName ==null || brzName ==""){
			$.scojs_message("请选择半日租收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var jjId = $('#jiejiAreaId_company').val().trim();
    	var jjName = $("#jiejiAreaId_company").next().find("a").text();
		if(jjId ==null  || jjId =="" || jjName ==null || jjName ==""){
			$.scojs_message("请选择接机收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var sjId = $('#songjiAreaId_company').val().trim();
    	var sjName = $("#songjiAreaId_company").next().find("a").text();
		if(sjId ==null  || sjId =="" || sjName ==null || sjName ==""){
			$.scojs_message("请选择送机收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var jzId = $('#jiezhanAreaId_company').val().trim();
    	var jzName = $("#jiezhanAreaId_company").next().find("a").text();
		if(jzId ==null  || jzId =="" || jzName ==null || jzName ==""){
			$.scojs_message("请选择接站收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var szId = $('#songzhanAreaId_company').val().trim();
    	var szName = $("#songzhanAreaId_company").next().find("a").text();
		if(szId ==null  || szId =="" || szName ==null || szName ==""){
			$.scojs_message("请选择送站收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		$.post('${ctx}/zhuanche/startCarTypeCompany',
			{'carTypeId':$('#carTypeId').val(),'companyId':$('#companyId_company').val(),
			'tangzuAreaId':tzId,'rizuAreaId':rzId,'banrizuAreaId':brzId,
			'jiejiAreaId':jjId,'songjiAreaId':sjId,'jiezhanAreaId':jzId,
			'songzhanAreaId':szId,
			'companyName':$('#companyId_company').find("option:selected").text(),
			'tangzuAreaName':tzName,
			'rizuAreaName':rzName,
			'banrizuAreaName':brzName,
			'jiejiAreaName':jjName,
			'songjiAreaName':sjName,
			'jiezhanAreaName':jzName,
			'songzhanAreaName':szName},
			function(data){
	           if(data.success){
	                $.scojs_message(data.message, $.scojs_message.TYPE_OK);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }else{
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
		       }
		    },'json');
    });
    
    //修改公司开通车型
    $("#close_modal_company_update").click(function(){
		$('#dialog_carTypeCompany_update').modal("hide");
	});
	
	
	 $(document).on("click","#startService_company_update",function(){
	 	var tzId = $('#tangzuAreaId_company_update').val().trim();
		var tzName = $("#tangzuAreaId_company_update").next().find("a").text();
		if(tzId ==null || tzId =="" || tzName ==null || tzName =="请选择收费标准"){
			$.scojs_message("请选择立即用车收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var rzId = $('#rizuAreaId_company_update').val().trim();
		var rzName = $("#rizuAreaId_company_update").next().find("a").text();
		if(rzId ==null || rzId =="" || rzName ==null || rzName =="请选择收费标准"){
			$.scojs_message("请选择日租收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var brzId = $('#banrizuAreaId_company_update').val().trim();
		var brzName = $("#banrizuAreaId_company_update").next().find("a").text();
		if(brzId ==null || brzId =="" || brzName ==null || brzName =="请选择收费标准"){
			$.scojs_message("请选择半日租收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var jjId = $('#jiejiAreaId_company_update').val().trim();
		var jjName = $("#jiejiAreaId_company_update").next().find("a").text();
		if(jjId ==null || jjId =="" || jjName ==null || jjName =="请选择收费标准"){
			$.scojs_message("请选择接机收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var sjId = $('#songjiAreaId_company_update').val().trim();
		var sjName = $("#songjiAreaId_company_update").next().find("a").text();
		if(sjId ==null || sjId =="" || sjName ==null || sjName =="请选择收费标准"){
			$.scojs_message("请选择送机收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var jzId = $('#jiezhanAreaId_company_update').val().trim();
		var jzName = $("#jiezhanAreaId_company_update").next().find("a").text();
		if(jzId ==null || jzId =="" || jzName ==null || jzName =="请选择收费标准"){
			$.scojs_message("请选择接站收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		var szId = $('#songzhanAreaId_company_update').val().trim();
		var szName = $("#songzhanAreaId_company_update").next().find("a").text();
		if(szId ==null || szId =="" || szName ==null || szName =="请选择收费标准"){
			$.scojs_message("请选择送站收费标准！", $.scojs_message.TYPE_ERROR);
			return false;
		}
		$.post('${ctx}/zhuanche/updateCarTypeCompany',
			{'carTypeId':$("#carTypeId_update").val(),'companyId':$('#companyId_update').val(),'companyName':$("#companyName_update").html(),
			'tangzuAreaId':tzId,'rizuAreaId':rzId,'banrizuAreaId':brzId,
			'jiejiAreaId':jjId,'songjiAreaId':sjId,'jiezhanAreaId':jzId,
			'songzhanAreaId':szId,
			'tangzuAreaName':tzName,
			'rizuAreaName':rzName,
			'banrizuAreaName':brzName,
			'jiejiAreaName':jjName,
			'songjiAreaName':sjName,
			'jiezhanAreaName':jzName,
			'songzhanAreaName':szName},
			function(data){
	           if(data.success){
	                $.scojs_message(data.message, $.scojs_message.TYPE_OK);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }else{
	                $.scojs_message(data.message, $.scojs_message.TYPE_ERROR);
	                setTimeout(function(){
						window.location.reload(true);
					}, 1000);
		       }
		    },'json');
		
    });
</script>
</@override>
<@extends name="../layout.ftl"/>
